// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

const { ccclass, property } = cc._decorator;

@ccclass
export default class AppleScale extends cc.Component {

    // @property(cc.Label)
    // label: cc.Label = null;

    // @property
    // text: string = 'hello';

    // LIFE-CYCLE CALLBACKS:

    onLoad() {

        let _desWidth = cc.view.getDesignResolutionSize().width;
        let _desHeight = cc.view.getDesignResolutionSize().height;

        let _realWidth = cc.view.getVisibleSizeInPixel().width;
        let _realHeight = cc.view.getVisibleSizeInPixel().height;

        let _ratioDes = _desWidth / _desHeight;
        let _ratioReal = _realWidth / _realHeight;

        let rito = 1;
        if (_ratioReal < _ratioDes) {
            rito = (_realWidth / _realHeight) / (_desWidth / _desHeight);
        }

        this.node.scale = rito;
    }

    start() {

    }

    // update (dt) {}
}
